package CardGame;

import java.util.ArrayList;
import java.util.List;
import java.util.Random;

public class CardGame {
    public  static final String[] suits={"♥","♠","♣","♦"};
    //1.买扑克；
    public List<Card> buyCard(){
        List<Card> cardList=new ArrayList<>();
        for(int i=0;i<4;i++){
            for(int j=1;j<=13;j++){
                String suit=suits[i];
                int rank=j;
                Card card=new Card(suit,rank);
                cardList.add(card);
            }
        }
        return cardList;
    }
//2.洗扑克；
    public List<Card> showCard(List<Card> cardList){
        Random random=new Random();
        for(int i=cardList.size()-1;i>0;i--){
            int index= random.nextInt(i);
            swap(cardList,i,index);
        }
        return cardList;
    }
    public void swap(List<Card> cardList, int i, int j){
        Card tmp=cardList.get(i);
        cardList.set(i,cardList.get(j));
        cardList.set(j,tmp);

    }
}
